package com.lkz.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lkz.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;


@Controller
public class CountController {
    @Autowired
    private IEmployeeService employeeService;
    @Autowired
    private ICustomerService customerService;
    @Autowired
    private IOrdersService ordersService;
    @Autowired
    private IDepartmentService departmentService;
     @Autowired
    private IBusinessService businessService;
    @Autowired
    private IContactService contactService;

    @GetMapping("/welcome")
    public String count(Model model){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("is_del",0);
        model.addAttribute("employee", employeeService.count(queryWrapper));
        model.addAttribute("customer", customerService.count(queryWrapper));
        model.addAttribute("orders", ordersService.count(queryWrapper));
        model.addAttribute("department", departmentService.count(queryWrapper));
        model.addAttribute("business", businessService.count(queryWrapper));
        model.addAttribute("contact", contactService.count(queryWrapper));
        return "welcome";
    }
}